#include<stdio.h>
#include<stdlib.h>
#include<filesystem>
using namespace std;

typedef struct student{
    int num;
    char name[10];
    char gender;
    struct student *next; 
}*stu;
stu add(stu head){
    if(head==NULL){
        head=(stu)malloc(sizeof(struct student));
        head->next=NULL;
    }
    stu node=(stu)malloc(sizeof(struct student));
    scanf("%d %s %c",&node->num,node->name,&node->gender);
    node->next=head->next;
    head->next=node;
    return head;
}
void print_stu(stu head){
    stu p=head->next;
    while(p){
        printf("%d\t%s\t%c\n",p->num,p->name,p->gender);
        p=p->next;
    }
}
void del_by_num(stu head,char x){
    stu p=head->next;
    stu pre=p;
    int flag=0;
    if(p->num==x){//待删除的是头节点
        stu temp=head;
        head=head->next;
        free(temp);
        flag=1;
    }
    pre=p;
    p=p->next;
    while(p){
        if(p->num==x){
            stu temp=p;
            pre->next=p->next;
            free(temp);
            flag=1;
        }
        pre=p;
        p=p->next;
    }
    if(flag==1){
        printf("don find x!");
    }
}
int main(){
    stu head=NULL;
    head=add(head);
    print_stu(head);
    del_by_num(head,'1');
    print_stu(head);
    return 0;
}